package com.education.mapper;

import com.education.domain.Tbcourse;
import com.education.domain.TbcourseExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TbcourseMapper {
    @SelectProvider(type=TbcourseSqlProvider.class, method="countByExample")
    int countByExample(TbcourseExample example);

    @DeleteProvider(type=TbcourseSqlProvider.class, method="deleteByExample")
    int deleteByExample(TbcourseExample example);

    @Delete({
        "delete from tbcourse",
        "where lId = #{lid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer lid);

    @Insert({
        "insert into tbcourse (strCourseCode, strCourseName, ",
        "nGrade, lTeacherId)",
        "values (#{strcoursecode,jdbcType=VARCHAR}, #{strcoursename,jdbcType=VARCHAR}, ",
        "#{ngrade,jdbcType=INTEGER}, #{lteacherid,jdbcType=INTEGER})"
    })
    @Options(useGeneratedKeys=true,keyProperty="lid")
    int insert(Tbcourse record);

    @InsertProvider(type=TbcourseSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="lid")
    int insertSelective(Tbcourse record);

    @SelectProvider(type=TbcourseSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="lId", property="lid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="strCourseCode", property="strcoursecode", jdbcType=JdbcType.VARCHAR),
        @Result(column="strCourseName", property="strcoursename", jdbcType=JdbcType.VARCHAR),
        @Result(column="nGrade", property="ngrade", jdbcType=JdbcType.INTEGER),
        @Result(column="lTeacherId", property="lteacherid", jdbcType=JdbcType.INTEGER)
    })
    List<Tbcourse> selectByExample(TbcourseExample example);

    @Select({
        "select",
        "lId, strCourseCode, strCourseName, nGrade, lTeacherId",
        "from tbcourse",
        "where lId = #{lid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="lId", property="lid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="strCourseCode", property="strcoursecode", jdbcType=JdbcType.VARCHAR),
        @Result(column="strCourseName", property="strcoursename", jdbcType=JdbcType.VARCHAR),
        @Result(column="nGrade", property="ngrade", jdbcType=JdbcType.INTEGER),
        @Result(column="lTeacherId", property="lteacherid", jdbcType=JdbcType.INTEGER)
    })
    Tbcourse selectByPrimaryKey(Integer lid);

    @UpdateProvider(type=TbcourseSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Tbcourse record, @Param("example") TbcourseExample example);

    @UpdateProvider(type=TbcourseSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Tbcourse record, @Param("example") TbcourseExample example);

    @UpdateProvider(type=TbcourseSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Tbcourse record);

    @Update({
        "update tbcourse",
        "set strCourseCode = #{strcoursecode,jdbcType=VARCHAR},",
          "strCourseName = #{strcoursename,jdbcType=VARCHAR},",
          "nGrade = #{ngrade,jdbcType=INTEGER},",
          "lTeacherId = #{lteacherid,jdbcType=INTEGER}",
        "where lId = #{lid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Tbcourse record);
}